<template>
    <a-card :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
            <h2 class="text-center  margin-bottom">{{title}}</h2>
            <a-form layout="inline" @keyup.enter.native="searchQuery">
                <a-row :gutter="24">
                </a-row>
            </a-form>
        </div>
        <!-- 查询区域-END -->

        <!-- 操作按钮区域 -->
        <div class="table-operator">
            <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
        </div>

        <!-- table区域-begin -->
        <div>
            <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
                <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
                selectedRowKeys.length }}</a>项
                <a style="margin-left: 24px" @click="onClearSelected">清空</a>
            </div>

            <a-table
                    ref="table"
                    size="middle"
                    :scroll="{x:true}"
                    bordered
                    rowKey="id"
                    :columns="columns"
                    :dataSource="dataSource"
                    :pagination="ipagination"
                    :loading="loading"
                    class="j-table-force-nowrap"
                    @change="handleTableChange">
<!--                :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"-->

                <template slot="htmlSlot" slot-scope="text">
                    <div v-html="text"></div>
                </template>
                <template slot="imgSlot" slot-scope="text">
                    <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
                    <img v-else :src="getImgView(text)" height="25px" alt=""
                         style="max-width:80px;font-size: 12px;font-style: italic;"/>
                </template>
                <template slot="fileSlot" slot-scope="text">
                    <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
                    <a-button
                            v-else
                            :ghost="true"
                            type="primary"
                            icon="download"
                            size="small"
                            @click="downloadFile(text)">
                        下载
                    </a-button>
                </template>

                <span slot="action" slot-scope="text, record">
                  <a @click="handleEdit(record)">编辑</a>

                  <a-divider type="vertical"/>
                  <a-dropdown>
                    <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
                    <a-menu slot="overlay">
                      <a-menu-item>
                        <a @click="handleDetail(record)">详情</a>
                      </a-menu-item>
                      <a-menu-item>
                        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                          <a>删除</a>
                        </a-popconfirm>
                      </a-menu-item>
                    </a-menu>
                  </a-dropdown>
                </span>

            </a-table>
        </div>

        <hc-article-modal ref="modalForm" @ok="modalFormOk"></hc-article-modal>
    </a-card>
</template>

<script>

    /**
     * create by Jane
     * 文章信息列表
     */
    import '@/assets/less/TableExpand.less'
    import { mixinDevice } from '@/utils/mixin'
    import { JeecgListMixin } from '@/mixins/JeecgListMixin'
    import HcArticleModal from './modules/HcArticleModal'

    export default {
        mixins: [JeecgListMixin, mixinDevice],
        components: {
            HcArticleModal
        },
        data() {
            return {
                title: '文章信息管理',
                // 表头
                columns: [
                    {
                        title: '#',
                        dataIndex: '',
                        key: 'rowIndex',
                        width: 60,
                        align: 'center',
                        customRender: function(t, r, index) {
                            return parseInt(index) + 1
                        }
                    },
                    {
                        title: '此废物名称',
                        align: 'center',
                        dataIndex: 'wasteName'
                    },
                    {
                        title: '医院提交废物重量',
                        align: 'center',
                        dataIndex: 'wasteOriginalValue'
                    },
                    {
                        title: '客户编号',
                        align: 'center',
                        dataIndex: 'customerNumber'
                    },
                    {
                        title: '提交人id',
                        align: 'center',
                        dataIndex: 'submitId'
                    },
                    {
                        title: '收运人id',
                        align: 'center',
                        dataIndex: 'recyclePersonId'
                    },
                    {
                        title: '收运状态（1-已提交（待收运），2-已收运）',
                        align: 'center',
                        dataIndex: 'recycleBagStatus'
                    },
                    {
                        title: '收运编号',
                        align: 'center',
                        dataIndex: 'recycleNumber'
                    },
                    {
                        title: '收运袋编码',
                        align: 'center',
                        dataIndex: 'recycleBagCode'
                    },
                    {
                        title: '收运请求提交用户电话',
                        align: 'center',
                        dataIndex: 'submitUserMobile'
                    },
                    {
                        title: '机构详细地址',
                        align: 'center',
                        dataIndex: 'customerAddress'
                    },
                    {
                        title: '废物父类型id',
                        align: 'center',
                        dataIndex: 'wasteParentId'
                    },
                    {
                        title: '废物类型',
                        align: 'center',
                        dataIndex: 'wasteType'
                    },
                    {
                        title: '收运时间',
                        align: 'center',
                        dataIndex: 'recycleTime',
                        customRender: function(text) {
                            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
                        }
                    },
                    {
                        title: '收运需求提交人姓名',
                        align: 'center',
                        dataIndex: 'submitUserName'
                    },
                    {
                        title: '提交人类型（1-医院，2-收运员）',
                        align: 'center',
                        dataIndex: 'submitType'
                    },
                    {
                        title: '收运人姓名',
                        align: 'center',
                        dataIndex: 'recyclePersonName'
                    },
                    {
                        title: '废物父类型名称',
                        align: 'center',
                        dataIndex: 'wasteParentName'
                    },
                    {
                        title: '收运人电话',
                        align: 'center',
                        dataIndex: 'recyclePersonPhone'
                    },
                    {
                        title: '部门id（大医院科室id）',
                        align: 'center',
                        dataIndex: 'departmentId'
                    },
                    {
                        title: '实际收运重量',
                        align: 'center',
                        dataIndex: 'wastePresentValue'
                    },
                    {
                        title: '单位（KG、袋、桶......）',
                        align: 'center',
                        dataIndex: 'priceUnit'
                    },
                    {
                        title: '机构名称',
                        align: 'center',
                        dataIndex: 'customerName'
                    },
                    {
                        title: '市',
                        align: 'center',
                        dataIndex: 'city'
                    },
                    {
                        title: '市编码',
                        align: 'center',
                        dataIndex: 'cityCode'
                    },
                    {
                        title: '省编码',
                        align: 'center',
                        dataIndex: 'provinceCode'
                    },
                    {
                        title: '省',
                        align: 'center',
                        dataIndex: 'province'
                    },
                    {
                        title: '区县',
                        align: 'center',
                        dataIndex: 'area'
                    },
                    {
                        title: '区县编码',
                        align: 'center',
                        dataIndex: 'areaCode'
                    },
                    {
                        title: '删除标注（0-未删，1-已删）',
                        align: 'center',
                        dataIndex: 'delFlag'
                    },
                    {
                        title: '处理单位id',
                        align: 'center',
                        dataIndex: 'companysId'
                    },
                    {
                        title: '操作',
                        dataIndex: 'action',
                        align: 'center',
                        fixed: 'right',
                        width: 147,
                        scopedSlots: { customRender: 'action' }
                    }
                ],
                url: {
                    list: '/hc/hcRecycleBagcode/list',
                    delete: '/hc/hcRecycleBagcode/delete',
                    deleteBatch: '/hc/hcRecycleBagcode/deleteBatch',

                },
                dictOptions: {},
                superFieldList: []
            }
        },
        created() {
            this.getSuperFieldList()
        },
        methods: {
            initDictConfig() {
            },
            getSuperFieldList() {
                let fieldList = []
                fieldList.push({ type: 'string', value: 'wasteName', text: '此废物名称' })
                fieldList.push({ type: 'number', value: 'wasteOriginalValue', text: '医院提交废物重量' })
                fieldList.push({ type: 'string', value: 'customerNumber', text: '客户编号' })
                fieldList.push({ type: 'string', value: 'submitId', text: '提交人id' })
                fieldList.push({ type: 'string', value: 'recyclePersonId', text: '收运人id' })
                fieldList.push({ type: 'string', value: 'recycleBagStatus', text: '收运袋状态（1-已提交（待收运），2-已收运）' })
                fieldList.push({ type: 'string', value: 'recycleNumber', text: '收运编号' })
                fieldList.push({ type: 'string', value: 'recycleBagCode', text: '收运袋编码' })
                fieldList.push({ type: 'string', value: 'submitUserMobile', text: '收运请求提交用户电话' })
                fieldList.push({ type: 'string', value: 'customerAddress', text: '机构详细地址' })
                fieldList.push({ type: 'string', value: 'wasteParentId', text: '废物父类型id' })
                fieldList.push({ type: 'string', value: 'wasteType', text: '废物类型' })
                fieldList.push({ type: 'date', value: 'recycleTime', text: '收运时间' })
                fieldList.push({ type: 'string', value: 'submitUserName', text: '收运需求提交人姓名' })
                fieldList.push({ type: 'string', value: 'submitType', text: '提交人类型（1-医院，2-收运员）' })
                fieldList.push({ type: 'string', value: 'recyclePersonName', text: '收运人姓名' })
                fieldList.push({ type: 'string', value: 'wasteParentName', text: '废物父类型名称' })
                fieldList.push({ type: 'string', value: 'recyclePersonPhone', text: '收运人电话' })
                fieldList.push({ type: 'string', value: 'departmentId', text: '部门id（大医院科室id）' })
                fieldList.push({ type: 'number', value: 'wastePresentValue', text: '实际收运重量' })
                fieldList.push({ type: 'string', value: 'priceUnit', text: '单位（KG、袋、桶......）' })
                fieldList.push({ type: 'string', value: 'customerName', text: '机构名称' })
                fieldList.push({ type: 'string', value: 'city', text: '市' })
                fieldList.push({ type: 'string', value: 'cityCode', text: '市编码' })
                fieldList.push({ type: 'string', value: 'provinceCode', text: '省编码' })
                fieldList.push({ type: 'string', value: 'province', text: '省' })
                fieldList.push({ type: 'string', value: 'area', text: '区县' })
                fieldList.push({ type: 'string', value: 'areaCode', text: '区县编码' })
                fieldList.push({ type: 'string', value: 'delFlag', text: '删除标注（0-未删，1-已删）' })
                fieldList.push({ type: 'string', value: 'companysId', text: '处理单位id' })
                this.superFieldList = fieldList
            }
        }
    }
</script>
<style scoped>
    @import '~@assets/less/common.less';
</style>
